<?php

namespace App\Service\UserCenter;

use App\Helpers\AliyunUtil;
use App\Helpers\ConfigUtil;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 技能列表
 */
class SkillListService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        $profile = UserProfile::getProfile($userId);
        $mySkills = $profile->skills ? explode(',', $profile->skills) : [];
        $skills = ConfigUtil::getSkills();
        $colors = ['#FFE0DF', '#FFF2E0', '#E5F0FE', '#E9E5FE'];
        foreach ($skills as $k => $skill) {
            $ret['list'][] = [
                'bg_color' => $colors[$k % 4],
                'skill' => $skill['skill'],
                'selected' => in_array($skill['skill'], $mySkills) ? 1 : 0,
                'desc' => $skill['desc'],
                'icon' => AliyunUtil::IMG_HOST . $skill['icon']
            ];
        }
        return $ret;
    }
}
